/*
 * @Author: hechengfei h349187021@163.com
 * @Date: 2022-08-15 10:49:49
 * @LastEditors: hechengfei h349187021@163.com
 * @LastEditTime: 2022-08-23 15:46:03
 * @FilePath: \xiangmu\src\store\contractStore.js
 * @Description: 这是默认设置,请设置`customMade`, 打开koroFileHeader查看配置 进行设置: https://github.com/OBKoro1/koro1FileHeader/wiki/%E9%85%8D%E7%BD%AEa
 */
import { makeAutoObservable } from 'mobx'
import Service from '../service';
class contractStore {
    constructor() {
        makeAutoObservable(this)
    }
    isdisplayDetalSearch = false;
    DisplayContractInfo = [];
    displayrenewalinfo = [];
    contractuserinp = {};
    contractStutebyno = '';
    changecontractinfo = {};
    addcontractinfo = {};
    feedlist = {}
    total = ''
    currentPage = 1;
    pageSize = 10
    getDetalSaerch() {
        this.isdisplayDetalSearch = !this.isdisplayDetalSearch
    }
    //所有合同信息
    getcontractData({ currentPage, pageSize }) {
        return new Promise((resovle, reject) => {
            Service.contractServiceAll.contractService.getcontractquerylist({ currentPage, pageSize }).then((data) => {
                resovle(data)
                this.DisplayContractInfo = data.data.data
                this.total = data.data.data.length
                console.log('所有合同信息', this.DisplayContractInfo);
            }).catch((err) => {
                reject(err)
            })
        })
    }
    //今日新增合同
    getcontracttodayaddData({ currentPage, pageSize }) {
        return new Promise((resovle, reject) => {
            Service.contractServiceAll.contractService.getcontracttodayadd({ currentPage, pageSize }).then((data) => {
                resovle(data)
                this.DisplayContractInfo = data.data.data
                this.total = data.data.data.length
                console.log('今日新增合同', this.DisplayContractInfo);
            }).catch((err) => {
                reject(err)
            })
        })
    }
    //本周新增合同
    getcontractweekaddData({ currentPage, pageSize }) {
        return new Promise((resovle, reject) => {
            Service.contractServiceAll.contractService.getcontractweekadd({ currentPage, pageSize }).then((data) => {
                resovle(data)
                this.DisplayContractInfo = data.data.data
                this.total = data.data.data.length
                console.log('本周新增合同', this.DisplayContractInfo);
            }).catch((err) => {
                reject(err)
            })
        })
    }
    //本月新增合同
    getcontractmonthaddData({ currentPage, pageSize }) {
        return new Promise((resovle, reject) => {
            Service.contractServiceAll.contractService.getcontractmonthadd({ currentPage, pageSize }).then((data) => {
                resovle(data)
                this.DisplayContractInfo = data.data.data
                this.total = data.data.data.length
                console.log('本月新增合同', this.DisplayContractInfo);
            }).catch((err) => {
                reject(err)
            })
        })
    }
    //参看合同续费
    getconractrenewaltable({ contract_no, currentPage, pageSize }) {
        return new Promise((resovle, reject) => {
            Service.contractServiceAll.contractService.getRenewallist({ contract_no, currentPage, pageSize }).then((data) => {
                resovle(data)
                this.displayrenewalinfo = data.data.data
                console.log('参看合同续费', this.displayrenewalinfo)
            }).catch((err) => {
                reject(err)
            })
        })
    }
    //今日到期
    getconractduetotoday({ currentPage, pageSize }) {
        return new Promise((resovle, reject) => {
            Service.contractServiceAll.contractService.getcontractduetoday({ currentPage, pageSize }).then((data) => {
                resovle(data)
                this.DisplayContractInfo = data.data.data
                this.total = data.data.data.length
                console.log('参看合同续费', this.displayrenewalinfo)
            }).catch((err) => {
                reject(err)
            })
        })
    }
    //本周到期
    getconractduetoweek({ currentPage, pageSize }) {
        return new Promise((resovle, reject) => {
            Service.contractServiceAll.contractService.getcontractdueweek({ currentPage, pageSize }).then((data) => {
                resovle(data)
                this.DisplayContractInfo = data.data.data
                this.total = data.data.data.length
                console.log('参看合同续费', this.displayrenewalinfo)
            }).catch((err) => {
                reject(err)
            })
        })
    }
    //本月到期
    getconractduetomonth({ currentPage, pageSize }) {
        return new Promise((resovle, reject) => {
            Service.contractServiceAll.contractService.getcontractduemonth({ currentPage, pageSize }).then((data) => {
                resovle(data)
                this.DisplayContractInfo = data.data.data
                this.total = data.data.data.length
                console.log('参看合同续费', this.displayrenewalinfo)
            }).catch((err) => {
                reject(err)
            })
        })
    }
    //新增客户
    getcustomertoadd(obj) {
        return new Promise((resovle, reject) => {
            Service.contractServiceAll.contractService.getcustomeradd(obj).then((data) => {
                resovle(data)
                console.log('新增客户', data.data)
            }).catch((err) => {
                reject(err)
            })
        })
    }
    //修改合同状态
    getchangestatue(obj) {
        return new Promise((resovle, reject) => {
            console.log(obj);
            Service.contractServiceAll.contractService.changestute(obj).then((data) => {
                resovle(data)
                console.log('修改合同状态', data.data)
            }).catch((err) => {
                reject(err)
            })
        })
    }
    //修改合同到款
    getchangetomoneycome(obj) {
        return new Promise((resovle, reject) => {
            Service.contractServiceAll.contractService.changegetmoney(obj).then((data) => {
                resovle(data)
                console.log('修改合同到款', data.data)
            }).catch((err) => {
                reject(err)
            })
        })
    }
    //修改合同信息
    getchangecontractinfobyname(obj) {
        return new Promise((resovle, reject) => {
            Service.contractServiceAll.contractService.changecontractinfobyname(obj).then((data) => {
                resovle(data)
                console.log('修改合同信息', data.data)
            }).catch((err) => {
                reject(err)
            })
        })
    }
    // 新增合同信息
    getaddcontractinfo(obj) {
        return new Promise((resovle, reject) => {
            Service.contractServiceAll.contractService.addcontractinfo(obj).then((data) => {
                resovle(data)
                console.log('新增合同信息', data.data)
            }).catch((err) => {
                reject(err)
            })
        })
    }
    //删除合同信息
    getdeletecontractinfobyno(contract_no) {
        return new Promise((resovle, reject) => {
            Service.contractServiceAll.contractService.deletecontractinfobyno(contract_no).then((data) => {
                resovle(data)
                console.log('删除合同信息', data.data)
            }).catch((err) => {
                reject(err)
            })
        })
    }
    // 高级搜索
    getsearchcontractinfoall(obj) {
        return new Promise((resovle, reject) => {
            Service.contractServiceAll.contractService.searchcontractinfoall(obj).then((data) => {
                resovle(data)
                console.log('高级搜索', data.data)
            }).catch((err) => {
                reject(err)
            })
        })
    }
    //搜索
    getsearchcontractinfo(obj) {
        return new Promise((resovle, reject) => {
            Service.contractServiceAll.contractService.searchcontractinfo(obj).then((data) => {
                resovle(data)
                this.DisplayContractInfo = data.data.data
                console.log('搜索', data.data)
            }).catch((err) => {
                reject(err)
            })
        })
    }
    // 续费
    getsearchfeedlist(obj) {
        return new Promise((resovle, reject) => {
            Service.contractServiceAll.contractService.searchfeedlist(obj).then((data) => {
                resovle(data)
                console.log('续费', data.data)
            }).catch((err) => {
                reject(err)
            })
        })
    }
    // 新增续费
    getaddfeedlist(obj) {
        return new Promise((resovle, reject) => {
            Service.contractServiceAll.contractService.addfeedlist(obj).then((data) => {
                resovle(data)
                console.log('新增续费', data.data)
            }).catch((err) => {
                reject(err)
            })
        })
    }
}
export default contractStore